//
// Created by hunan on 25-2-20.
//

#include "socket_connection_util.h"
#include "socket_connection.h"
#include "tcp_socket_connection.h"
#include "tls_socket_connection.h"
#include "udp_socket_connection.h"

#include <memory>

std::shared_ptr<SocketConnection> SocketConnectionUtil::CreateSocketConnection(int mode, Loop * loop)
{
    std::shared_ptr<SocketConnection> connect = nullptr;
    switch (mode)
    {
        case SocketConnection::EmConnectionTypeTcp:
        {
            connect = std::make_shared<TcpSocketConnection>(loop);
            break;
        }
        case SocketConnection::EmConnectionTypeTcpTls:
        {
            connect = std::make_shared<TlsSocketConnection>(loop);
            break;
        }
        case SocketConnection::EmConnectionTypeUdp:
        {
            connect = std::make_shared<UdpSocketConnection>(loop);
            break;
        }
        default:
            break;
    }
    return connect;
}
